package dome1;//验证 A man,a plan, a canal, Panama

import java.util.Locale;
import java.util.Scanner;

public class text3 {
    public static boolean isNumberAndCharacter(char str){//注意此时要判断的是单个字符是否是数字字母字符；
        if(Character.isDigit(str)||Character.isLetter(str)){
            return true;
        }
        return false;
    }
    public static boolean fun(String str){
        String str1=str.toLowerCase();
        int left=0;
        int right=str1.length()-1;
        while(left<right){
            while(left<right&&!(isNumberAndCharacter(str1.charAt(left)))){
                left++;
            }
            while(left<right&&!(isNumberAndCharacter(str1.charAt(right)))){
                right--;
            }
            if(str1.charAt(left)==str1.charAt(right)){
                left++;
                right--;
            }else{
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你要验证的回文串");
        String str= scanner.nextLine();
        boolean str3=fun(str);
        System.out.print("是否是回文字符串："+str3);

    }

}
